﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CMS.BLL;
using CMS.BLL.Entity;

public partial class AdminX_EntryVisa_EntryVisaDetails : System.Web.UI.UserControl
{
    private int nDefaultLang = Support.GetDefaultLanguage();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            setLable();
            BindDataWhenEdit();
        }
    }

    protected void setLable()
    {
        lblArrivalDate.Text = MultipleLanguage.LBL_ARRIVIALDATE[nDefaultLang - 1];
        lblConfirmEmail.Text = MultipleLanguage.CONFIRMEMAIL[nDefaultLang - 1];
        lblContactFullname.Text = MultipleLanguage.LBL_FULLNAME[nDefaultLang - 1];
        lblDOB.Text = MultipleLanguage.LBL_DATEOFBIRTH[nDefaultLang - 1];
        lblEmail.Text = MultipleLanguage.EMAIL[nDefaultLang - 1];
        lblExitDate.Text = MultipleLanguage.LBL_EXITDATE[nDefaultLang - 1];
        lblExpiryDate.Text = MultipleLanguage.LBL_EXPIRYDATE[nDefaultLang - 1];
        lblFax.Text = MultipleLanguage.LBL_FAX[nDefaultLang - 1];
        lblFullName.Text = MultipleLanguage.LBL_FULLNAME[nDefaultLang - 1];
        lblGender.Text = MultipleLanguage.LBL_GENDER[nDefaultLang - 1];
        lblHomeAddress.Text = MultipleLanguage.LBL_HOMEADDRESS[nDefaultLang - 1];
        lblNationality.Text = MultipleLanguage.LBL_NATIONLITY[nDefaultLang - 1];
        lblNumberOfEntry.Text = MultipleLanguage.LBL_NUMBEROFENTRY[nDefaultLang - 1];
        lblOtherRequest.Text = MultipleLanguage.LBL_OTHERREQUEST[nDefaultLang - 1];
        lblPassportNo.Text = MultipleLanguage.LBL_PASSPORTNO[nDefaultLang - 1];
        lblPayment.Text = MultipleLanguage.LBL_PAYMENT[nDefaultLang - 1];
        lblPortOfArrival.Text = MultipleLanguage.PORTOFARRIVAL[nDefaultLang - 1];
        lblPurposeOfEntry.Text = MultipleLanguage.LBL_PURPOSEOFENTRY[nDefaultLang - 1];
        lblTel.Text = MultipleLanguage.LBL_TEL[nDefaultLang - 1];
        lblVisaPeriod.Text = MultipleLanguage.LBL_VISAPERIOD[nDefaultLang - 1];
        btnBack.Text = MultipleLanguage.BTN_BACK[nDefaultLang];
    }
    private void BindDataWhenEdit()
    {
        string sAction = ConvertData.ConvertToString(Request.QueryString[Config.ACTION]);
        try
        {
            if (sAction == Config.ACTION_EDIT)
            {
                int nID = ConvertData.ConvertToInt(Request.QueryString[Config.ACTION_ID]);
                if (nID > 0)
                    GetData(nID);
            }
        }
        catch
        {
            string sLink = Config.ROOT + Pages.BackEnds.ADMIN + "?" + Config.PAGE + "=" + Pages.BackEnds.STR_ENTRYVISA;
            Response.Redirect(sLink);
        }
    }
    private void GetData(int nID)
    {
        EntryVisa objEntryVisa = new EntryVisa();
        objEntryVisa.LoadById(nID);

        lblValConfirmEmail.Text = objEntryVisa.Data.ConfirmEmail;
        lblValContactFullname.Text = objEntryVisa.Data.FullName;
        lblValDate1.Text = ConvertData.ConvertIntToDatetimeString(objEntryVisa.Data.ArrivalDate);
        
        lblValDate2.Text = ConvertData.ConvertIntToDatetimeString(objEntryVisa.Data.ExitDate);
        lblValHomeAddress.Text = ConvertData.ConvertToString(objEntryVisa.Data.Address);
        lblValNumberOfEntry.Text = ConvertData.ConvertToString(objEntryVisa.Data.NumberOfEntry);
        lblValOtherRequest.Text = ConvertData.ConvertToString(objEntryVisa.Data.OtherRequest);
        lblValFax.Text = ConvertData.ConvertToString(objEntryVisa.Data.Fax);
        lblValEmail.Text = ConvertData.ConvertToString(objEntryVisa.Data.Email);

        bool check = false;
        if (objEntryVisa.Data.FullName1.Trim() != "")
        {
            lblValFullName1.Text = ConvertData.ConvertToString(objEntryVisa.Data.FullName1);
            if(objEntryVisa.Data.ExpiryDate1.ToString().Length == 8)
                lblValExpiry1.Text = ConvertData.ConvertIntToDatetimeString(objEntryVisa.Data.ExpiryDate1);
            lblValNationality1.Text = ConvertData.ConvertToString(objEntryVisa.Data.Nationality1);
            lblValPassport1.Text = ConvertData.ConvertToString(objEntryVisa.Data.PassportNo1);
            if (objEntryVisa.Data.DoB1.ToString().Length == 8)
                lblValDate3.Text = ConvertData.ConvertIntToDatetimeString(objEntryVisa.Data.DoB1);
            if (objEntryVisa.Data.Gender1 == 0)
                lblValGender11.Text = "Female";
            else
                lblValGender11.Text = "Male";

            check = true;
        }
        else
        {
            lblValFullName1.Visible = false;
            lblValExpiry1.Visible = false;
            lblValNationality1.Visible = false;
            lblValPassport1.Visible = false;
            lblValDate3.Visible = false;
            lblValGender11.Visible = false;
        }
        if (objEntryVisa.Data.FullName2.Trim() != "")
        {
            lblValFullName2.Text = ConvertData.ConvertToString(objEntryVisa.Data.FullName2);
            if (objEntryVisa.Data.ExpiryDate2.ToString().Length == 8)
                lblValExpiry2.Text = ConvertData.ConvertIntToDatetimeString(objEntryVisa.Data.ExpiryDate2);
            lblValNationality2.Text = ConvertData.ConvertToString(objEntryVisa.Data.Nationality2);
            lblValPassport2.Text = ConvertData.ConvertToString(objEntryVisa.Data.PassportNo2);
            if (objEntryVisa.Data.DoB2.ToString().Length == 8)
                lblValDate4.Text = ConvertData.ConvertIntToDatetimeString(objEntryVisa.Data.DoB2);
            if (objEntryVisa.Data.Gender2 == 0)
                lblValGender12.Text = "Female";
            else
                lblValGender12.Text = "Male";
            check = true;
        }
        else
        {
            lblValFullName2.Visible = false;
            lblValExpiry2.Visible = false;
            lblValNationality2.Visible = false;
            lblValPassport2.Visible = false;
            lblValDate4.Visible = false;
            lblValGender12.Visible = false;
        }

        if (objEntryVisa.Data.FullName3.Trim() != "")
        {
            lblValFullName3.Text = ConvertData.ConvertToString(objEntryVisa.Data.FullName3);
            if (objEntryVisa.Data.ExpiryDate3.ToString().Length == 8)
                lblValExpiry3.Text = ConvertData.ConvertIntToDatetimeString(objEntryVisa.Data.ExpiryDate3);
            lblValNationality3.Text = ConvertData.ConvertToString(objEntryVisa.Data.Nationality3);
            lblValPassport3.Text = ConvertData.ConvertToString(objEntryVisa.Data.PassportNo3);
            if (objEntryVisa.Data.DoB3.ToString().Length == 8)
                lblValDate5.Text = ConvertData.ConvertIntToDatetimeString(objEntryVisa.Data.DoB3);
            if (objEntryVisa.Data.Gender3 == 0)
                lblValGender13.Text = "Female";
            else
                lblValGender13.Text = "Male";
            check = true;
        }
        else
        {
            lblValFullName3.Visible = false;
            lblValExpiry3.Visible = false;
            lblValNationality3.Visible = false;
            lblValPassport3.Visible = false;
            lblValDate5.Visible = false;
            lblValGender13.Visible = false;
        }

        if (objEntryVisa.Data.FullName4.Trim() != "")
        {
            lblValFullName4.Text = ConvertData.ConvertToString(objEntryVisa.Data.FullName4);
            if (objEntryVisa.Data.ExpiryDate4.ToString().Length == 8)
                lblValExpiry4.Text = ConvertData.ConvertIntToDatetimeString(objEntryVisa.Data.ExpiryDate4);
            lblValNationality4.Text = ConvertData.ConvertToString(objEntryVisa.Data.Nationality4);
            lblValPassport4.Text = ConvertData.ConvertToString(objEntryVisa.Data.PassportNo4);
            if (objEntryVisa.Data.DoB4.ToString().Length == 8)
                lblValDate6.Text = ConvertData.ConvertIntToDatetimeString(objEntryVisa.Data.DoB4);
            if (objEntryVisa.Data.Gender4 == 0)
                lblValGender14.Text = "Female";
            else
                lblValGender14.Text = "Male";
            check = true;
        }
        else
        {
            lblValFullName4.Visible = false;
            lblValExpiry4.Visible = false;
            lblValNationality4.Visible = false;
            lblValPassport4.Visible = false;
            lblValDate6.Visible = false;
            lblValGender14.Visible = false;
        }

        if (objEntryVisa.Data.FullName5.Trim() != "")
        {
            lblValFullName5.Text = ConvertData.ConvertToString(objEntryVisa.Data.FullName5);
            if (objEntryVisa.Data.ExpiryDate5.ToString().Length == 8)
                lblValExpiry5.Text = ConvertData.ConvertIntToDatetimeString(objEntryVisa.Data.ExpiryDate5);
            lblValNationality5.Text = ConvertData.ConvertToString(objEntryVisa.Data.Nationality5);
            lblValPassport5.Text = ConvertData.ConvertToString(objEntryVisa.Data.PassportNo5);
            if (objEntryVisa.Data.DoB5.ToString().Length == 8)
                lblValDate7.Text = ConvertData.ConvertIntToDatetimeString(objEntryVisa.Data.DoB5);
            if (objEntryVisa.Data.Gender5 == 0)
                lblValGender15.Text = "Female";
            else
                lblValGender15.Text = "Male";
            check = true;
        }
        else
        {
            lblValFullName5.Visible = false;
            lblValExpiry5.Visible = false;
            lblValNationality5.Visible = false;
            lblValPassport5.Visible = false;
            lblValDate7.Visible = false;
            lblValGender15.Visible = false;
        }

        if (objEntryVisa.Data.FullName6.Trim() != "")
        {
            lblValFullName6.Text = ConvertData.ConvertToString(objEntryVisa.Data.FullName6);
            if (objEntryVisa.Data.ExpiryDate6.ToString().Length == 8)
                lblValExpiry6.Text = ConvertData.ConvertIntToDatetimeString(objEntryVisa.Data.ExpiryDate6);
            lblValNationality6.Text = ConvertData.ConvertToString(objEntryVisa.Data.Nationality6);
            lblValPassport6.Text = ConvertData.ConvertToString(objEntryVisa.Data.PassportNo6);
            if (objEntryVisa.Data.DoB6.ToString().Length == 8)
                lblValDate8.Text = ConvertData.ConvertIntToDatetimeString(objEntryVisa.Data.DoB6);
            if (objEntryVisa.Data.Gender6 == 0)
                lblValGender16.Text = "Female";
            else
                lblValGender16.Text = "Male";
            check = true;
        }
        else
        {
            lblValFullName6.Visible = false;
            lblValExpiry6.Visible = false;
            lblValNationality6.Visible = false;
            lblValPassport6.Visible = false;
            lblValDate8.Visible = false;
            lblValGender16.Visible = false;
        }

        if (objEntryVisa.Data.FullName7.Trim() != "")
        {
            lblValFullName7.Text = ConvertData.ConvertToString(objEntryVisa.Data.FullName7);
            if (objEntryVisa.Data.ExpiryDate7.ToString().Length == 8)
                lblValExpiry7.Text = ConvertData.ConvertIntToDatetimeString(objEntryVisa.Data.ExpiryDate7);
            lblValNationality7.Text = ConvertData.ConvertToString(objEntryVisa.Data.Nationality7);
            lblValPassport7.Text = ConvertData.ConvertToString(objEntryVisa.Data.PassportNo7);
            if (objEntryVisa.Data.DoB7.ToString().Length == 8)
                lblValDate9.Text = ConvertData.ConvertIntToDatetimeString(objEntryVisa.Data.DoB7);
            if (objEntryVisa.Data.Gender7 == 0)
                lblValGender17.Text = "Female";
            else
                lblValGender17.Text = "Male";
            check = true;
        }
        else
        {
            lblValFullName7.Visible = false;
            lblValExpiry7.Visible = false;
            lblValNationality7.Visible = false;
            lblValPassport7.Visible = false;
            lblValDate9.Visible = false;
            lblValGender17.Visible = false;
        }

        if (objEntryVisa.Data.FullName8.Trim() != "")
        {
            lblValFullName8.Text = ConvertData.ConvertToString(objEntryVisa.Data.FullName8);
            if (objEntryVisa.Data.ExpiryDate8.ToString().Length == 8)
                lblValExpiry8.Text = ConvertData.ConvertIntToDatetimeString(objEntryVisa.Data.ExpiryDate8);
            lblValNationality8.Text = ConvertData.ConvertToString(objEntryVisa.Data.Nationality8);
            lblValPassport8.Text = ConvertData.ConvertToString(objEntryVisa.Data.PassportNo8);
            if (objEntryVisa.Data.DoB8.ToString().Length == 8)
                lblValDate10.Text = ConvertData.ConvertIntToDatetimeString(objEntryVisa.Data.DoB8);
            if (objEntryVisa.Data.Gender8 == 0)
                lblValGender18.Text = "Female";
            else
                lblValGender18.Text = "Male";
            check = true;
        }
        else
        {
            lblValFullName8.Visible = false;
            lblValExpiry8.Visible = false;
            lblValNationality8.Visible = false;
            lblValPassport8.Visible = false;
            lblValDate10.Visible = false;
            lblValGender18.Visible = false;
        }

        if (!check)
        {
            lblFullName.Visible = false;
            lblGender.Visible = false;
            lblDOB.Visible = false;
            lblNationality.Visible = false;
            lblPassportNo.Visible = false;
            lblExpiryDate.Visible = false;
        }

        Payment objPayment = new Payment();
        objPayment.LoadById(objEntryVisa.Data.PaymentID);
        lblValPayment.Text = ConvertData.ConvertToString(objPayment.Data.Description);

        lblValPortOfArrival.Text = ConvertData.ConvertToString(objEntryVisa.Data.PortOfArrival);
        lblValPurposeOfEntry.Text = ConvertData.ConvertToString(objEntryVisa.Data.PurposeOfEntry);
        lblValTel.Text = ConvertData.ConvertToString(objEntryVisa.Data.Tel);
        lblValVisaPeriod.Text = ConvertData.ConvertToString(objEntryVisa.Data.VisaPeriod);

        int n = objEntryVisa.UpdateStatus(nID, EnumeType.ACTIVE);
    }
    protected void btnBack_Click(object sender, EventArgs e)
    {
        Response.Redirect(Config.ROOT + Pages.BackEnds.ADMIN + "?" + Config.PAGE + "=" + Pages.BackEnds.STR_ENTRYVISA);
    }
}
